class GameDetailData {
  late String v_id;
  late String g_id;
  late bool subscribed;
  late String name;
  late String status;
  late String status_name;
  late String date;
  late String time;
  late String week;
  late GameDetailDataVenue venue;
  late String focus_text;
  late String game_intro;
  late List<dynamic> sportsman;
  late String type;
  late GameDetailDataVideo? video;
  late String video_status;
  late String video_status_name;
  late String discipline_name;
  List<GameFilesModel>? files;
  String? gameUrl;
  String? rsc;

  GameDetailData(Map<String, dynamic> json) {
    this.v_id = "${json["v_id"]}";
    this.g_id = "${json["g_id"]}";
    try {
      this.discipline_name = json["discipline_name"] ?? '';
    } catch (e) {
      this.discipline_name = '';
    }
    try {
      this.subscribed = json["subscribed"] as bool;
    } catch (e) {
      this.subscribed = false;
    }
    this.name = "${json["name"]}";
    this.status = "${json["status"]}";
    this.status_name = "${json["status_name"]}";
    this.date = "${json["date"]}";
    this.time = "${json["time"]}";
    this.week = "${json["week"]}";
    this.gameUrl = json['game_url'] as String?;
    this.rsc = json['rsc'] as String?;
    if (json['files'] is List) {
      this.files = (json['files'] as List<dynamic>?)
          ?.map((e) => GameFilesModel.fromJson(e))
          .toList();
    }

    try {
      this.venue = GameDetailDataVenue(json["venue"]);
      this.game_intro = json["game_intro"] as String;
    } catch (e) {
      this.venue = GameDetailDataVenue({});
    }
    try {
      this.sportsman = json["sportsman"] as List<dynamic>;
    } catch (e) {
      this.sportsman = [];
    }
    this.focus_text = "${json["focus_text"]}";
    try {
      video = GameDetailDataVideo(json["video"]);
    } catch (e) {
      video = null;
    }
    this.type = "${json["v_type"]}";
    this.video_status = "${json["video_status"]}";
    this.video_status_name = "${json["video_status_name"]}";
  }

  Map<String, dynamic> get json {
    var result = Map<String, dynamic>();
    result["v_id"] = this.v_id;
    result["g_id"] = this.g_id;
    result["subscribed"] = subscribed;
    result["name"] = name;
    result["status"] = this.status;
    result["status_name"] = this.status_name;
    result["date"] = this.date;
    result["time"] = this.time;
    result["week"] = this.week;
    result["venue"] = this.venue.json;
    result["focus_text"] = this.focus_text;
    result["game_intro"] = this.game_intro;
    result["sportsman"] = sportsman;
    result["v_type"] = type;
    result["video_status"] = video_status;
    result["video_status_name"] = video_status_name;
    result["discipline_name"] = discipline_name;
    result['rsc'] = rsc;
    result['game_url'] = gameUrl;
    return result;
  }
}

class GameDetailDataVenue {
  late String id;
  late String name;
  late String address;
  late int game_count;
  late double long;
  late double lat;
  int? type;

  GameDetailDataVenue(Map<String, dynamic> json) {
    this.name = "${json["name"]}";
    this.address = "${json["address"]}";
    try {
      this.game_count = json["game_count"] as int;
    } catch (e) {
      this.game_count = 0;
    }
    try {
      this.long = double.parse("${json['long']}");
      lat = double.parse("${json['lat']}");
    } catch (e) {
      long = 0;
      lat = 0;
    }
    this.type = json['type'] as int?;
    this.id = "${json['id']}";
  }

  Map<String, dynamic> get json {
    var result = Map<String, dynamic>();
    result["name"] = this.name;
    result["address"] = this.address;
    result["game_count"] = this.game_count;
    result["long"] = long;
    result["lat"] = lat;
    result["id"] = id;
    result['type'] = type;
    return result;
  }
}

class GameDetailDataVideo {
  late String video_type;
  late List<GameDetailDataVideoOrigin> origin;
  GameDetailDataVideo(Map<String, dynamic> json) {
    this.video_type = "${json["video_type"]}";
    this.origin = (json["origin"] as List)
        .map((e) => GameDetailDataVideoOrigin(e))
        .toList();
  }
  Map<String, dynamic> get json {
    var result = Map<String, dynamic>();
    result["video_type"] = this.video_type;
    result["origin"] = this.origin.map((e) => e.json).toList();
    return result;
  }
}

class GameDetailDataVideoOrigin {
  late String name;
  late String url;
  late int duration;
  GameDetailDataVideoOrigin(Map<String, dynamic> json) {
    this.name = "${json["name"]}";
    this.url = "${json["url"]}";
    try {
      this.duration = int.parse("${json["duration"]}");
    } catch (e) {
      duration = 0;
    }
  }
  Map<String, dynamic> get json {
    var result = Map<String, dynamic>();
    result["name"] = this.name;
    result["url"] = this.url;
    result["duration"] = this.duration;
    return result;
  }
}

class GameFilesModel {
  String? file_path;
  String? name;

  GameFilesModel({
    this.file_path,
    this.name,
  });

  factory GameFilesModel.fromJson(Map<String, dynamic> json) {
    return GameFilesModel(
      file_path: json['file_path'] as String?,
      name: json['name'] as String?,
    );
  }

  Map<String, dynamic> toJson() => {
        'file_path': file_path,
        'name': name,
      };
}
